package bit.demo2;

class TestDemo {
    public static int count = 100;
}

public class Test {

    public static void main(String[] args) {

        Student student1 = new Student();
        System.out.println("===================");
        Student student2 = new Student();
        System.out.println(Student.classRoom);
    }

    public static void main7(String[] args) {
        {
            int a = 10;
            System.out.println(a);
        }

        //此时 a 的作用范围与生命周期都在上一个括号内，出了括号 a 就成未定义了
        //System.out.println(a);
    }

    public static void main6(String[] args) {
        Student student1 = new Student("张三",10);
        System.out.println(student1.getName());
    }

    public int add(int a,int b) {
        return a+b;
    }

    public static void main5(String[] args) {
        Student student1 = new Student("张三",10);
        student1.testFunc();
        System.out.println(student1.getName());

        Student.testStatic();

        Test test = new Test();
        test.add(1,2);
    }

    //有问题 count 未定义
    public static void main4(String[] args) {
        TestDemo testDemo = new TestDemo();
        TestDemo.count++;

        TestDemo testDemo2 = new TestDemo();
        testDemo2.count++;

        TestDemo.count--;
        TestDemo.count++;
        TestDemo.count++;
        System.out.println(TestDemo.count);
    }

    public static void main3(String[] args) {
        Student.classRoom = "118Java";
    }

    public static void main2(String[] args) {
        Student student1 = new Student("张三",10);
        Student.classRoom = "118Java";

        Student student2 = new Student("李四",20);

        //classRoom 被 Static 修饰,位于类下,不用带对象
        Student.classRoom = "118Java";
    }

    public static void main1(String[] args) {
        Student student = new Student("张三",10);

        //以下代码报错原因  —— >  name 属性是私有的（private）
        //student.name = "lisi";
        //System.out.println(student.name);

        student.setName("lisi");
        System.out.println(student.getName());
    }
}
